package com.wuhuahe.luanfeng.netty.example.rpc;

/**
 * Created By wuhuahe
 * author:游龙
 * Date: 2018-07-14
 * Time: 15:50
 * Desc:
 */
public class ResponseHolder {

    private RpcResponse response;

    public RpcResponse getResponse() throws InterruptedException {
        synchronized (this){
            wait(10000L);
        }
        return response;
    }

    public RpcResponse getResponse(long timeout) throws InterruptedException {
        synchronized (this){
            wait(timeout);
        }
        return response;
    }

    public void setResponse(RpcResponse response) {
        this.response = response;
        synchronized (this){
            notify();
        }
    }
}
